import React from 'react'
import PropTypes from 'prop-types'
import {Table} from 'antd'
import classnames from 'classnames'
import {Link} from 'react-router-dom'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import styles from './List.less'

const List = ({
                onDeleteItem, onLeaveItem, onEditItem, isMotion, location, ...tableProps
              }) => {

  const columns = [
    {
      title: '运营微号',
      dataIndex: 'operatorWxId',
      key: 'operatorWxId',
    }, {
      title: '归属员工',
      dataIndex: 'empName',
      key: 'empName',
    }, {
      title: '公司部门',
      dataIndex: 'deptName',
      key: 'deptName',
    }, {
      title: '好友微信号',
      dataIndex: 'dfriendWxId',
      key: 'dfriendWxId',

    }, {
      title: '好友昵称',
      dataIndex: 'friendNickName',
      key: 'friendNickName',
    }, {
      title: '好友备注',
      dataIndex: 'friendRemark',
      key: 'friendRemark',
    }, {
      title: '方向',
      dataIndex: 'msgDirection',
      key: 'msgDirection',
      render: msgDirection => msgDirection === true ? '转出' : '转入',
    }, {
      title: '方式',
      dataIndex: 'ways',
      key: 'ways',
      render: ways => {
        switch (ways) {
          case 0:
            return "微信红包"
          case 1:
            return "微信转账"
          case 2:
            return "提现"
          case 3:
            return "信用卡还款"
          default:
            return "数据异常"
        }
      },
    }, {
      title: '金额',
      dataIndex: 'amount',
      key: 'amount',
      render: (val) => val + '元',
    }, {
      title: '转账时间',
      dataIndex: 'transferTime',
      key: 'transferTime',

    }, {
      title: '记录详情',
      key: 'detail',
      render: () => <Link to={''}>详情</Link>,
    },
  ]

  const AnimateBody = (props) => {
    return <AnimTableBody {...props} />
  }

  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  return (
    <Table
      {...tableProps}
      className={classnames(styles.table, {[styles.motion]: isMotion})}
      scroll={{x: 1500}}
      columns={columns}
      simple
      rowKey={record => record.id}
      components={{
        body: {wrapper: isMotion ? AnimateBody : CommonBody},
      }}
    />
  )
}

List.propTypes = {
  onDeleteItem: PropTypes.func,
  onEditItem: PropTypes.func,
  isMotion: PropTypes.bool,
  location: PropTypes.object,
}

export default List
